package com.reremouse.rerebbs.web.mb;

import com.reremouse.model.SystemConfig;
import com.reremouse.rerebbs.dao.ISystemConfigDAO;
import com.reremouse.util.SpringHelper;

import javax.annotation.PostConstruct;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import java.io.Serializable;
import java.util.Map;

@ManagedBean
@ApplicationScoped
public class ApplicationBean
        implements Serializable {
    String siteName;
    String siteBackName;
    String keyWords;
    String description;
    String siteHeader;
    String copyRight;
    String contact;
    String path = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
    String filePath = "";
    SystemConfig systemConfig;
    ISystemConfigDAO systemConfigDAO = (ISystemConfigDAO) SpringHelper.getSpringBean("SystemConfigDAO");
    Map<String, String> themes = (Map) SpringHelper.getSpringBean("themes");

    public String getPath() {
        return this.path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getKeyWords() {
        return this.keyWords;
    }

    public String getFilePath() {
        return this.filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public void setKeyWords(String keyWords) {
        this.keyWords = keyWords;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getSiteName() {
        return this.siteName;
    }

    public void setSiteName(String siteName) {
        this.siteName = siteName;
    }

    public SystemConfig getSystemConfig() {
        return this.systemConfig;
    }

    public void setSystemConfig(SystemConfig systemConfig) {
        this.systemConfig = systemConfig;
    }

    public String getSiteBackName() {
        return this.siteBackName;
    }

    public void setSiteBackName(String siteBackName) {
        this.siteBackName = siteBackName;
    }

    public Map<String, String> getThemes() {
        return this.themes;
    }

    public void setThemes(Map<String, String> themes) {
        this.themes = themes;
    }

    public String getContact() {
        return this.contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getCopyRight() {
        return this.copyRight;
    }

    public void setCopyRight(String copyRight) {
        this.copyRight = copyRight;
    }

    public String getSiteHeader() {
        return this.siteHeader;
    }

    public void setSiteHeader(String siteHeader) {
        this.siteHeader = siteHeader;
    }

    @PostConstruct
    public void init() {
        this.systemConfig = this.systemConfigDAO.getSystemConfig();
        loadFilePath();
        loadInfo();
    }

    private void loadInfo() {
        this.siteName = ((String) SpringHelper.getSpringBean("siteName"));
        this.siteBackName = ((String) SpringHelper.getSpringBean("siteBackName"));
        this.keyWords = ((String) SpringHelper.getSpringBean("keyWords"));
        this.description = ((String) SpringHelper.getSpringBean("description"));
        this.siteHeader = ((String) SpringHelper.getSpringBean("siteHeader"));
        this.copyRight = ((String) SpringHelper.getSpringBean("copyRight"));
        this.contact = ((String) SpringHelper.getSpringBean("contact"));
    }

    public void loadFilePath() {
        String dir = "";
        boolean b = this.systemConfigDAO.getSystemConfig().getIfRelative().booleanValue();
        if (b) {
            String tp = this.systemConfigDAO.getSystemConfig().getFilePath();
            if (!tp.endsWith("/")) {
                tp = tp + "/";
            }
            dir = FacesContext.getCurrentInstance().getExternalContext().getRealPath(tp);
        } else {
            dir = this.systemConfigDAO.getSystemConfig().getFilePath();
        }
        if (!dir.endsWith("\\")) {
            dir = dir + "\\";
        }
        this.filePath = dir;
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.rerebbs.web.mb.ApplicationBean

 * JD-Core Version:    0.7.0.1

 */